package com.neborosoft.FlyingDog.android;

import android.app.Activity;
import android.content.ContentResolver;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.WindowManager;
import com.neborosoft.FlyingDog.R;
import com.neborosoft.FlyingDog.android.database.AndroidAudioDataBase;
import com.neborosoft.FlyingDog.android.playing.PlayingModeManager;
import com.neborosoft.FlyingDog.bitmap.ImageLoaderConfigFactory;
import com.neborosoft.FlyingDog.logic.database.AudioDataManager;
import com.neborosoft.FlyingDog.logic.database.LocalAudioDataBase;
import com.neborosoft.android.events.HistoryManager;
import com.neborosoft.android.gui.AndroidMenuManager;
import com.neborosoft.lib.collections.stack.HistoryStack;
import com.neborosoft.lib.handlers.OnHardwareBackPressed;
import com.neborosoft.lib.stream.TextLoader;
import com.neborosoft.lib.stream.TextLoaderConfig;
import com.neborosoft.lib.threading.OnHostThreadExecutor;
import com.neborosoft.lib.utilities.Utilities;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

public class MyActivity extends Activity{
    @Override
    public void onBackPressed() {
        HistoryManager.getInstance().popHardwareBackPressedListener();
    }

    @Override
    public void onAttachedToWindow()
    {
        this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
        super.onAttachedToWindow();
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        try
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            PlayingModeManager playingModeManager = new PlayingModeManager(this);
            FlyingDog.getInstance().onActivityCreated(this);
        }
        catch (Exception e)
        {
            Utilities.logException(e);
        }
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_menu, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if(AndroidMenuManager.getInstance().onOptionsItemSelected(item)){
            return true;
        }

        return super.onOptionsItemSelected(item);
    }

    @Override
    protected void onDestroy() {
        FlyingDog.getInstance().onActivityDestroyed(this);
    }
}